package com.zzyl.config;

import com.zzyl.constant.RedisQueueTopic;
import com.zzyl.listener.RedisQueueListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;

import javax.annotation.Resource;

@Configuration
public class RedisQueueConfig {

    @Resource
    RedisQueueListener redisQueueListener;
    @Bean
    public RedisConnectionFactory redisQueueConnectionFactory(RedisConnectionFactory redisConnectionFactory){
        RedisConnection connection = redisConnectionFactory.getConnection();
        connection.subscribe(redisQueueListener, RedisQueueTopic.TEST_TOPIC.getBytes());
        return redisConnectionFactory;
    }
}
